/*
 * Packet.h
 *
 *  Created on: Dec 2, 2011
 *      Author: dzm
 */

#ifndef _PACKETFORSEM_H_
#define _PACKETFORSEM_H_

#include <fstream>
#include <iostream>
#include <QString>
#include <QStringList>

#include "Header.h"
#include "GateWay.h"
#include "LEN.h"
//#include "RSA.h"

using namespace std;

class PacketForSem {
public:
	PacketForSem();
	virtual ~PacketForSem();
	void set(int num_of_unicast_turn,int num_of_multicast_turn, int num_of_des, int overlap, int seg , int hop);
	bool isLegalCo(string);
	void inputCo(DesNode& );
	void interactWithUser(unsigned short&, int&, DesNode&, QVector<DesNode>& );
	bool packetInitialize(QString , QString  , QString );
	bool packetInitialize(short srcCo[],short desCo[],unsigned short inport);
	bool packetInitialize();
	//排列节点顺序
	void sequence(QString , QString , QString);
	//QString坐标转为int数组
	int* QString2Co( QString );
	//计算转发出口
	int caculateOutport(int*, int* , int , int , int , int & ,bool &);
	int caculateOutport(int*, int , int & ,bool &);
	bool HandleMulticast(int& remain_num_of_multicast_turn,int* inport,int& count,int& index_of_pointer);
//	void TransformHeader(GateWay gw);
//	void getEncrKey(GateWay gw,int,int,PublicKey&);
	void allIP();
	bool isThisTree(int count,int maybe);
	int nearestMultiTurn(int count);
	int exactMultiTurn(int count);

	int** seqCo;
	short *source;
	unsigned short *inport;
	QString *turning;

	Header header;
	QString nextHeader;
	QString fileName;
	QString initNode;
	QByteArray load;
};

#endif /* _PACKETFORSEM_H_ */
